﻿using System;
using System.Windows.Input;

namespace Songhay.Wpf.Mvvm.ViewModel
{
    /// <summary>
    /// Represents an actionable item displayed by a View.
    /// </summary>
    /// <remarks>
    /// This design is useful for visualizing a set of known procedures.
    /// A set can be defined by <c>List&lt;CommandViewModel&gt;</c>,
    /// exposed for View-Model binding.
    /// 
    /// Based on the MVVM pattern from Josh Smith, http://joshsmithonwpf.wordpress.com/
    /// </remarks>
    public class CommandViewModel : ViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandViewModel"/> class.
        /// </summary>
        /// <param name="displayName">The display name.</param>
        /// <param name="command">The command.</param>
        public CommandViewModel(string displayName, ICommand command)
        {
            if(command == null)
                throw new ArgumentNullException("command");

            base.DisplayName = displayName;
            this.Command = command;
        }

        /// <summary>
        /// Gets or sets the <see cref="System.Windows.Input.ICommand"/>.
        /// </summary>
        /// <value>The Windows input command.</value>
        public ICommand Command { get; set; }
    }
}
